function main() {
    let formPartEle = this.$$element("form_part_h1o69w");
    let pageRenderElement = this.$$root().$parent.$parent.$parent;
    debugger
    const regionId = self.$$("text_input_37yviy").cValue;
    const regionCode = self.$$("text_input_4wq2kj").cValue;


    if (formPartEle) {
        formPartEle.$$getRenderElement().onSave()
            .then((res) => {
                if (res) {
                    getStallOrganizationCode(regionId, regionCode).then(stallOrganizationCode => {
                        updateStallOrganizationCode(res.documentNo, stallOrganizationCode).then(res => {
                            console.log("保存成功");
                            pageRenderElement.goHistory(-1);
                        })
                    })

                } else {
                    console.log("保存失败");
                }
            })
    }
}


function getStallOrganizationCode(stallOrganizationCode, regionCode) {
    const params = [{
        name: "stall_organization_code",
        valueContent: stallOrganizationCode
    }, {
        name: "regionCode",
        valueContent: regionCode
    }];

    return new Promise(resolve => {
        api.DATA_SOURCE_EXECUTE("38f50199-1493-460e-807b-f54b57d3a3bb", "api", params, [], []).then((res) => {
            console.log(res);
            resolve(res.data[0].stall_organization_code);
        }).catch(err => {
            console.log(err);
        });
    })
}

